package org.jvnc.rfb.proto;

/**
* <br><br><center><table border="1" width="80%"><hr>
* <p>
* Copyright (C) 2006-2007 by Deon Wu
* <p>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.0
* of the License, or (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU Lesser General Public License</a>
* for more details.
* <p>
* You should have received a copy of the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">
* GNU Lesser General Public License</a> along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* <hr></table></center>
* **/

import gnu.rfb.PixelFormat;

import java.io.DataInput;
import java.io.IOException;

import org.jvnc.rfb.proto.encoding.*;

public class Rectangle extends AbstractDataGram {
	private int positionX;
	private int positionY;
	private int width;
	private int height;
	private int   codingType;
	private Encoding encoding;
	
	private PixelFormat format = null;
	
	public void readData( DataInput input ) throws IOException
	{
		positionX = input.readUnsignedShort();
		positionY = input.readUnsignedShort();
		width = input.readUnsignedShort();
		height = input.readUnsignedShort();
		
		codingType = input.readInt();
		
		/*
		log.debug("Rect (X,Y,withd,height,Ending),(" +
				positionX + "," +
				positionY + "," +
				width + "," +
				height + "," +
				codingType +")"
				);
		*/
		
		switch(codingType){
			case Encoding.RAW:
				encoding = new Raw(this);
				break;
			case Encoding.RRE:
				encoding = new RRE(this);
				break;
			case Encoding.CopyRect:
				encoding = new CopyRect(this);
				break;
			case Encoding.Hextile:
				encoding = new Hextile(this);
				break;
			case Encoding.ZRLE:
				encoding = new ZRLE(this);
			case Encoding.Cursor:
				encoding = new CursorPseudo(this);
		}
		encoding.fillEncoding(input);
	}

	public int getCodingType() {
		return codingType;
	}

	public void setCodingType(int codingType) {
		this.codingType = codingType;
	}

	public Encoding getEncoding() {
		return encoding;
	}

	public void setEncoding(Encoding encoding) {
		this.encoding = encoding;
	}

	public PixelFormat getFormat() {
		return format;
	}

	public void setFormat(PixelFormat format) {
		this.format = format;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getPositionX() {
		return positionX;
	}

	public void setPositionX(int positionX) {
		this.positionX = positionX;
	}

	public int getPositionY() {
		return positionY;
	}

	public void setPositionY(int positionY) {
		this.positionY = positionY;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}
	
}
